<template>
	<div class="home">
		<cmd-nav-bar iconOne="menu" back left-text="选择品种" right-text="确定" @rightText="toLoss"></cmd-nav-bar>
		<div class="not_thing"></div>
		<div class="var_box" v-for="n in allarray" @click="to_org(n)" :class="{border_org: n.flag }">
			{{n.name}}
		</div>
	</div>
</template>
<script>
	import cmdNavBar from "@/components/cmd-nav-bar/cmd-nav-bar.vue"
	import {
		Loadmore
	} from 'mint-ui';
	export default {

		props: {},
		components: {
			cmdNavBar,
			Loadmore
		},
		data() {
			return {
				phones: null,
				allarray: [],

				statuval: [{
						"name": "全部",
						"flag": false,
					}, {
						"name": "未找到",
						"flag": false,
					},
					{
						"name": "已找到",
						"flag": false,
					}
				],
				love: [{
						"name": "全部",
						"flag": false,
					}, {
						"name": "已配对",
						"flag": false,
					},
					{
						"name": "未配对",
						"flag": false,
					}
				],
				adopt: [{
						"name": "全部",
						"flag": false,
					}, {
						"name": "已领养",
						"flag": false,
					},
					{
						"name": "未领养",
						"flag": false,
					}
				],
				val: '全部',
				falgclass: 1,
			}
		},
		methods: {
			to_org(n) {
				this.allarray.map(function(item) {
					if (item.name != n.name) {
						item.flag = false
					} else {
						n.flag = true
					}
					return item
				});

			},
			toLoss() {
				this.allarray.map(function(item) {
					if (item.flag == true) {
						localStorage.setItem('seekstatu', item.name);
					}
				});

				uni.navigateTo({
					url: 'loss'
				});

			}
		},
		watch: {},

		onReachBottom() { //页面上拉触底事件的处理函数

		},
		onPullDownRefresh() { //监听用户下拉动作，一般用于下拉刷新
			//需要在 pages.json 里，找到的当前页面的pages节点，并在 style 选项中开启 enablePullDownRefresh
			//uni.startPullDownRefresh(); 开启
			// uni.stopPullDownRefresh(); 关闭
		},
		onUnload() { //监听页面卸载

		},
		onHide() { //监听页面隐藏

		},
		onLoad() { // 替代 created 监听页面加载，其参数为上个页面传递的数据，参数类型为Object（用于页面传参），参考示例
		},
		onReady() { //替代 mounted 监听页面初次渲染完成
			this.falgclass = location.href.split("=")[1]
			console.log(this.falgclass)
			if (this.falgclass == 1) {

				this.allarray = this.statuval
			} else(
				this.allarray = this.love
			)
			switch (this.falgclass) {
				case "1":
					this.allarray = this.statuval
					break;
				case "2":
					this.allarray = this.love
					break;
				case "3":
					this.allarray = this.adopt
					break;
			}

		},

		onShow() { //监听页面显示
			//生命周期
		}
	}
</script>
<style scoped>
	.home {
		width: 100%;
		height: 100%;
	}

	.not_thing {
		width: 100%;
		height: 18vw;
		background: #f8f8f8;
	}

	.var_box {
		height: 8vw;
		width: 25vw;
		margin-left: 5.6vw;
		margin-top: 20upx;
		float: left;
		border-radius: 10upx;
		border: 1px solid #b1b0b0;
		text-align: center;
		line-height: 8vw;
	}

	.border_org {
		color: #26a2ff;
		border: 1px solid #26a2ff;
	}
</style>
